Xbasic

STRWORDITRAN Function

Syntax

Output_String as C = STRWORDITRAN(C character,C substring,[C replacement,[N start_pos,[N occurrences[,N every]]]])

Arguments

character

A character string.

substring

The word to find in the character string.

replacement

Default = "" (NULL). The word that replaces the substring. Optional.

start_pos

Default = 1. Specifies which (and subsequent) occurrences will be replaced. A value N for the optional start_pos begins the replacement at the N th occurrence of substring. Numeric

occurrences

Optional. Default = All. Specifies the maximum number of occurrences of substring to replace with replacement. Numeric

every

Numeric

Description

Replaces each occurrence of a word with another - compare is case insensitive.

Discussion

Looks for a substring in a character string, and replaces every occurrence of it with a replacement. If replacement is omitted, substring is replaced with NULL characters. A value N for the optional start_pos begins the replacement at the N th occurrence of Word. A value for the optional Occurrences specifies the maximum number of occurrences of Word to be replaced. STRWORDITRAN() is case insensitive. Note : You can use STRWORDTRAN() with memo fields.

Example

strworditran("partnership is the most important part of part of a successful relationship", "part", "element") -> "partnership is the most important element of element of a successful relationship"
STRTRAN("partnership is the most important part of part of a successful relationship", "part", "element") -> "elementnership is the most important element of element of a successful relationship"
strworditran("She sells sea shell on the sea shore","sea","ocean", 2, 1) -> "She sells sea shell on the ocean shore"

See Also